/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.service.BaseService;
import com.chlitina.store.modules.expert.dao.SolutionFaceCareDao;
import com.chlitina.store.modules.expert.dao.SolutionFaceDao;
import com.chlitina.store.modules.expert.entity.SolutionFaceCare;
import com.chlitina.store.modules.expert.entity.SolutionFaceProductMix;

/**
 * 方案护理关联Service
 * @author liujiang
 * @version 2013-11-05
 */
@Component
@Transactional(readOnly = true)
public class SolutionFaceCareService extends BaseService {

	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(SolutionFaceCareService.class);
	
	@Autowired
	private SolutionFaceCareDao solutionFaceCareDao;
	@Autowired
	private SolutionFaceDao solutionFaceDao;
	
	public SolutionFaceCare getOneByPK(Long sid, Long cid) {
		return solutionFaceCareDao.findByPKId(sid, cid);
	}
	
	public List<SolutionFaceCare> getBySolutionFace(long SolutionFaceId,
			long locationSeason, long storeTypeId){
		return solutionFaceCareDao.getBySolutionFace(SolutionFaceId, locationSeason, storeTypeId);
	}
	
	public Page<SolutionFaceCare> find(Page<SolutionFaceCare> page, Long solutionId) {
		DetachedCriteria dc = solutionFaceCareDao.createDetachedCriteria();
		if (solutionId != null) {
			dc.add(Restrictions.eq("solutionFace.id", solutionId));
		}
		return solutionFaceCareDao.find(page, dc);
	}
	
	@Transactional(readOnly = false)
	public void save(SolutionFaceCare solutionFaceCare) {
		solutionFaceCareDao.save(solutionFaceCare);
		solutionFaceDao.refresh(solutionFaceCare.getSolutionFace());
	}
	
	public List<SolutionFaceCare> getBySolutionFaceId(Long sid) {
		return solutionFaceCareDao.findBySolutionId(sid);
	}
	
	@Transactional(readOnly = false)
	public void delete(SolutionFaceCare solutionFaceCare) {
		solutionFaceCareDao.delete(solutionFaceCare);
	}
	
}
